<form action="/admin_categories/save" method="post">

    <? if (! isset($category)): ?>
        <? if (isset($parent)): ?>
            <h1><?= $parent->name ?> &raquo; Nova podkategorija</h1>
        <? else: ?>
            <h1>Nova kategorija</h1>
        <? endif ?>
    <? else: ?>
        <h1><?= $category->name ?></h1>
    <? endif ?>

    <?= $this->hidden(array('data', 'id'), @$category->id) ?>
    <? if (isset($parent)): ?>
        <?= $this->hidden(array('data', 'parent_id'), $parent->id); ?>
    <? endif ?>

    <p><?= $this->text(array('data', 'name'), array(
        'value' => @$category->name,
        'label' => 'Naziv:'
    )) ?></p>
    <p><?= $this->checkbox(array('data', 'menu'), array(
        'label' => 'Prikaz u meniju',
        'checked' => ((int)@$category->menu)>0
    )) ?>
    <?= $this->checkbox(array('data', 'homepage'), array(
        'label' => 'Prikaz na naslovnoj strani',
        'checked' => ((int)@$category->homepage)>0
    )) ?></p>

    <p><?= $this->submit('Sačuvaj') ?><? if(@$category->id): ?>
    <?= $this->link('Obriši', "/admin_categories/remove/{$category->id}", array(
        'class'   => 'right input delete',
        'confirm' => 'Da li želite da obrišete kategoriju?'
    )) ?>
    <?= $this->link('Dodaj podkategoriju', "/admin_categories/add/{$category->id}", array(
        'remote' => true,
        'onclick'=>"location.hash='!'+$(this).data('url')",
        'data' => array(
            'before'   => 'categoryLoading()',
            'complete' => 'editCategory(req)'
        ),
        'class'  => 'right input'
    )) ?><? endif ?></p>
</form>

<script type="text/javascript">
initRemoteLinks($('form [data-remote]'));
</script>